package com.smart.community.property.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.List;

/**
 * 费用重复检查结果DTO
 * 
 * @author Wu.Liang
 * @since 2025-01-30
 * @version 1.0.0
 */
@Data
@Schema(description = "费用重复检查结果")
public class FeeDuplicateCheckResult {

    @Schema(description = "是否存在重复")
    private boolean hasDuplicate;

    @Schema(description = "重复检查类型：community-社区级别，household-房户级别")
    private String checkType;

    @Schema(description = "重复的费用记录数量")
    private int duplicateCount;

    @Schema(description = "重复的费用记录列表")
    private List<DuplicateFeeRecord> duplicateRecords;

    @Schema(description = "错误消息")
    private String errorMessage;

    @Schema(description = "重叠的月份列表")
    private List<String> overlappingMonths;

    /**
     * 重复的费用记录
     */
    @Data
    @Schema(description = "重复的费用记录")
    public static class DuplicateFeeRecord {
        
        @Schema(description = "费用ID")
        private Long feeId;
        
        @Schema(description = "费用编号")
        private String feeNo;
        
        @Schema(description = "房户ID")
        private Long householdId;
        
        @Schema(description = "房户地址")
        private String householdAddress;
        
        @Schema(description = "计费周期")
        private String billingPeriod;
        
        @Schema(description = "费用金额")
        private String amount;
        
        @Schema(description = "支付状态")
        private Integer paymentStatus;
        
        @Schema(description = "创建时间")
        private String createTime;
    }

    /**
     * 创建无重复的结果
     */
    public static FeeDuplicateCheckResult noDuplicate() {
        FeeDuplicateCheckResult result = new FeeDuplicateCheckResult();
        result.setHasDuplicate(false);
        result.setDuplicateCount(0);
        return result;
    }

    /**
     * 创建有重复的结果
     */
    public static FeeDuplicateCheckResult hasDuplicate(String checkType, int duplicateCount, 
                                                      List<DuplicateFeeRecord> duplicateRecords, 
                                                      List<String> overlappingMonths) {
        FeeDuplicateCheckResult result = new FeeDuplicateCheckResult();
        result.setHasDuplicate(true);
        result.setCheckType(checkType);
        result.setDuplicateCount(duplicateCount);
        result.setDuplicateRecords(duplicateRecords);
        result.setOverlappingMonths(overlappingMonths);
        return result;
    }

    /**
     * 创建错误结果
     */
    public static FeeDuplicateCheckResult error(String errorMessage) {
        FeeDuplicateCheckResult result = new FeeDuplicateCheckResult();
        result.setHasDuplicate(false);
        result.setErrorMessage(errorMessage);
        return result;
    }
}
